package com.qk.mapper;

import com.qk.entity.Course;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CourseMapper {
    //1. 课程列表查询
    List<Course> selectList(String name, Integer subject, Integer target);
    //2. 删除课程
    @Delete("delete from course where id = #{id}")
    void deleteById(Integer id);
    //3. 添加课程
    @Insert("insert into course( name, subject, price, target, description, create_time, update_time) values(#{name},#{subject},#{price},#{target},#{description},#{createTime},#{updateTime})")
    void insert(Course course);
    //4. 根据ID查询
    @Select("select id, name, subject, price, target, description, create_time, update_time from course where id = #{id}")
    Course selectById(Integer id);
    //5. 修改课程
    void update(Course course);
    //6. 查询所有课程
    @Select("select id, name, subject, price, target, description, create_time, update_time from course")
    List<Course> selectAll();
     //7. 根据学科查询课程
    @Select("select id, name, subject, price, target, description, create_time, update_time from course where subject = #{subject}")
    List<Course> listBySubject(Integer subject);
}
